﻿import mx.utils.Delegate;
class cn.eminia.ComboClassV1.list {
	var lastSel;
	var ss, tt, ft, tb; 
	var page:MovieClip;
	var btn, sld, pg;
	var popup;
	// 定义: 带滚动条的列表
	function list(popup, data, vars) {
		ss = 1;
		popup = popup;
		page = popup.page;
		var bs = new cn.eminia.AS2.BoGV3();
		if (vars.css != null) {
			ft = new TextFormat();
			cn.eminia.AS2.ASCSS.parse(ft, vars.css);
		}
		//var dele:MovieClip=page.creatEmptyMovieClip("comboPage", "comboPage", 1);
		//dele.attachMovie("",);
		tb = new cn.eminia.AS2.Flash.Table(page.ori, '1*' + data.length, 0, 0, '|', 
		Delegate.create(this, 
			function (evt) {
				evt.oo.tf.text = data[evt.id];
				//
				evt.oo.tf.setTextFormat(ft);
				//
				evt.oo.tf._width = vars.width;
				evt.oo.rr._x = vars.width-3;
				evt.oo.bb._width = vars.width-1;
				evt.oo.bg._width = vars.width-1;
				evt.oo.bg._x = 1;
				new cn.eminia.AS2.BoEV3(evt.oo, Delegate.create(this, 
					function (evt) 
					{
						tt = evt.oo.tf.text;
						lastSel.useHandCursor = 1;
						lastSel = evt.oo;
						lastSel.useHandCursor = 0;
						//trace(evt.id)
						//trace(evt.oo.gid)
						evt.oo.bg.gotoAndStop('click'); 
						vars.Esel({id:evt.id, vv:evt.oo.tf.text, oo:evt.oo});
						ss = 0;
					}
				), { over:Delegate.create(this, 
					function (evt) 
					{
						if (evt.oo != lastSel) {
							evt.oo.bg.gotoAndStop('over');
						}
						vars.Eover({id:evt.id, vv:evt.oo.tf.text, oo:evt.oo});
					}
				), out:Delegate.create(this, 
					function (evt) 
					{
						if (evt.oo != lastSel) {
							evt.oo.bg.gotoAndStop('defined');
						}
						vars.Eout({id:evt.id, vv:evt.oo.tf.text, oo:evt.oo});
					}
				)
				});
				if (evt.id + 1 == data.length) 
				{
					evt.oo.bb._visible = 0;
				}
				bs.push(evt.oo);
			}
		));
		//bs.set(0);
		popup._x = (vars.offset) ? vars.offset : 0;
		popup.msk._height = popup.page.ori._height*vars.num;
		popup.msk._width = vars.width;
		//
		//trace('49   '+data.length+' | '+(data.length<vars.num)+' | '+vars.num);
		if (data.length<=vars.num) {
			popup.scroll._visible = false;
			return;
		} else{
			popup.scroll._visible = true;
		}
		popup.scroll.bar._y = popup.scroll.btn0._y+popup.scroll.btn0._height;
		
		popup.scroll._x = vars.width-popup.scroll._width;
		popup.scroll.axis._height = popup.msk._height-popup.scroll.btn1._height*2;
		popup.scroll.axis._y = popup.scroll.btn0._height;
		popup.scroll.btn1._y = popup.msk._height-popup.scroll.btn1._height;
		// 
		btn = new cn.eminia.RClassV3.Btn(popup.scroll.btn0, popup.scroll.btn1);
		sld = new cn.eminia.RClassV3.Slider('|', 
								{
									bar:popup.scroll.bar, 
									axis:popup.scroll.axis 
								}
		);
		pg = new cn.eminia.RClassV3.Page('|', 
								{
									msk:popup.msk, 
									page:popup.page
								}
							);
		cn.eminia.RClassV3.Util.bind(sld, pg, btn);
		trace("page._height = "+ page._height )
		trace("page._y = "+ page._y )
	}
	function killMe() {
		cn.eminia.RClassV3.Util.unbind(btn, sld, pg);
		
		trace("--------------------"  )
		//trace("btn = "+ btn )
		//trace("sld = "+ sld )
		//trace("pg = "+ pg ) 
		
		//trace("EXE---------- pg " + pg);
		//trace("EXE---------- pg " + pg.dispose);
		
		//trace("EXE---------- sld " + sld);
		//trace("EXE---------- sld " + sld.dispose);
		
		pg.dispose();
		btn.dispose();
		sld.dispose();
		
		
		pg = null;
		btn = null;
		sld = null;
		
		//trace("--------------------"  )
		//trace("btn = "+ btn )
		//trace("sld = "+ sld )
		//trace("pg = " + pg ) 
		//
		tb.killMe(); 
		page._y = 0; 
		popup.scroll.bar._y = 0;
		
		
		trace("EXE---------- popup.scroll.bar " + popup.scroll.bar);
		trace("EXE---------- popup.scroll.bar._y " + popup.scroll.bar._y);
		trace("page._height = "+ page._height )
		trace("page._y = "+ page._y )
	}
}
